import { defineStore } from 'pinia'
import { ref } from 'vue'
import api from '../services/api'

export const useMenuStore = defineStore('menu', () => {
  const menuList = ref([]) // 初始化为空数组

  const getMenuList = async () => {
    try {
      const response = await api.getmeList()
      // 确保 response.data.menus 是一个数组
      menuList.value = response.data.menus || []
    } catch (error) {
      console.error('Failed to fetch menu list:', error)
    }
  }
//暴露给外部
  return { menuList, getMenuList }
}, 
{
  persist: true // 如果需要持久化存储
})